C
C *** LAST REVISED ON 20-JUL-1987 17:07:58.65
C *** SOURCE FILE: [DL.GRAPHICS.LONGLIB]CONTRLC.FOR
C
C ***********************************************************************
C
C CODE ADDED TO LONGLIB TO HANDLE CONTROL-C INTERUPTS FROM THE TERMINAL
C FIRST WRITTEN BY: D. LONG     MAY 1987
C
C SUBROUTINES WHICH PERMIT CONTROL-C INTERUPTS IN LONGLIB ROUTINES
C THIS SUBROUTINES ARE REPLACE EXISTING ROUTINES IN THE LONGLIB FILE
C TO ALLOWS CONTROL-C INTERRUPTS.  VERY MACHINE DEPENDENT STUFF.
C
C TO USE THE CONTROL-C INTERUPT CAPABILITY, CALL THE ROUTINE ENABLEAST
C FROM USER PROGRAM.  THIS ESTABLISHES AN QIO CHANNEL TO THE TERMINAL AND
C ENABLES THE CONTROL-C INTERRUPT.  LONGLIB DOES NOT HAVE TO BE USED TO
C GET THE CONTROL-C INTERRUPT.  YOU CAN WRITE YOUR OWN HANDLER TO REPLACE
C THE THE CODE BELOW.  SEE THE ROUTINE, ASTINTER.
C
C OBVIOUSLY, THIS CODE IS VERY MACHINE DEPDENDENT.
C
C
C ***********************************************************************
C
	SUBROUTINE ENABLEAST
C
C	CALL THIS ROUTINE FROM MAIN PROGRAM TO ENABLE CONTROL-C INTERUPTS
C
	COMMON/ASTC/IASTFL,IASTPL
	INTEGER ENAST
C
C	ENABLE QIO CONTROL-C INTERRUPTS
C
	ICHAR=ENAST(4)
	IASTFL=0
	RETURN
	END
C
C
	INTEGER FUNCTION ENAST(IOPT)
C
C	ENABLES CONTROL-C INTERRUPTS ON TERMINAL USING QIOW CALL
C	ALSO OPENS CHANNEL TO TERMINAL
C	RETURNS -1 WHEN AN IO ERROR OCCURS
C
C	VERY VAX MACHINE DEPENDENT
C
	INTEGER*2 ICHAN,IOSB(4)
	INTEGER*4 I1,SYS$QIOW,IO$_SETMODE,IO$M_CTRLCAST
	EXTERNAL SYS$QIOW,IO$_SETMODE,IO$M_CTRLCAST
	EXTERNAL ASTEXIT
	COMMON /TT_IO/ICHAN
	DATA ICHAN/0/
C
	IF (ICHAN.EQ.0) THEN
		CALL SYS$ASSIGN('TT',ICHAN,,)
		I1=%LOC(IO$_SETMODE).OR.%LOC(IO$M_CTRLCAST)
	ENDIF
	ENAST=SYS$QIOW(,%VAL(ICHAN),%VAL(I1),IOSB,,,%REF(ASTEXIT),IOPT,
     $		,%VAL(3),,,)
	RETURN
	END
